<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>钩子函数-背景颜色</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="case11-demo4">
    <div v-runoob="{backgroudColor:'red',text:'moe',color:'white'}"></div>
</div>
<script type="text/javascript">
    Vue.directive("runoob",function (el,binding) {
        //简写方式设置文本及背景颜色
        el.innerHTML=binding.value.text
        el.style.backgroundColor=binding.value.backgroudColor
        el.style.color=binding.value.color
        el.onclick=function () {
            alert("Hello World!!!")
        }
    })
    new Vue({
        el:"#case11-demo4"
    })
</script>
</body>
</html>